package com.jdls.service;

import com.jdls.mapper.ProvinceMapper;
import com.jdls.pojo.Province;
import com.jdls.utils.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

import java.util.List;

/**
 * @author 嘉德罗斯
 * @date 2021/9/6
 */
public class ProvinceService {

    public List<Province> selectAll(){
        SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
        SqlSession sqlSession = sqlSessionFactory.openSession();
        ProvinceMapper mapper = sqlSession.getMapper(ProvinceMapper.class);
        List<Province> provinces = mapper.selectAll();
        sqlSession.close();
        return provinces;
    }

    public List<Province> select(){
        SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
        SqlSession sqlSession = sqlSessionFactory.openSession();
        ProvinceMapper mapper = sqlSession.getMapper(ProvinceMapper.class);
        List<Province> select = mapper.select();
        sqlSession.close();
        return select;
    }
}
